package partitionBean;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;
import serializeBean.FlowBean;

import java.io.IOException;

public class FlowCountReducer extends Reducer<Text,FlowBean,Text,FlowBean> {
    protected void reduce(Text key,Iterable<FlowBean> values,Context context) throws IOException, InterruptedException {
        long sumUpFlow = 0;
        long sumDownFlow = 0;
        for (FlowBean bean:values) {
            sumUpFlow += bean.getUpFlow();
            sumDownFlow += bean.getDownFlow();
        }
        context.write(key,new FlowBean(sumUpFlow,sumDownFlow));
    }
}
